package co.chuangdian.oflauncher;

import java.util.Date;

import org.json.JSONObject;

import android.content.Intent;
import cn.onekit.*;
import cn.onekit.android.ACTIVITY;

public class OFActivity extends ACTIVITY{

	@Override
	protected void onResume() {
		super.onResume();
		String[] no_check = new String[]{"SplashActivity","LockScreenActivity"};
		for(String item : no_check){
			if(getClass().getSimpleName().equalsIgnoreCase(item)){
				break;
			}
			if(CONFIG.get("AppPauseTime")==null){
				break;
			}
			CONFIG.set("AppPauseTime",null);
			JSONObject setting = JSON.parse(CONFIG.get("setting"));
			JSONObject setting_lockscreen = setting.optJSONObject("lockscreen");
			if(!setting_lockscreen.optBoolean("switch")){
				break;
			}
			Intent intent=new Intent(this,LockScreenActivity.class);
			//intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
			startActivity(intent);
		}
	}
	@Override  
    protected void onStop() {  
        super.onStop();  

        if (!isAppOnForeground()) {  
               CONFIG.set("AppPauseTime", new Date().getTime()); 
        }  
	}
}
